package com.easemob.cloud;

import internal.org.apache.http.entity.mime.HttpMultipartMode;
import internal.org.apache.http.entity.mime.MultipartEntity;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.Charset;

class CustomMultiPartEntity extends MultipartEntity
{
  private final ProgressListener a;

  public CustomMultiPartEntity(ProgressListener paramProgressListener)
  {
    this.a = paramProgressListener;
  }

  public CustomMultiPartEntity(HttpMultipartMode paramHttpMultipartMode, ProgressListener paramProgressListener)
  {
    super(paramHttpMultipartMode);
    this.a = paramProgressListener;
  }

  public CustomMultiPartEntity(HttpMultipartMode paramHttpMultipartMode, String paramString, Charset paramCharset, ProgressListener paramProgressListener)
  {
    super(paramHttpMultipartMode, paramString, paramCharset);
    this.a = paramProgressListener;
  }

  public void writeTo(OutputStream paramOutputStream)
    throws IOException
  {
    super.writeTo(new CountingOutputStream(paramOutputStream, this.a));
  }

  public static class CountingOutputStream extends FilterOutputStream
  {
    private final CustomMultiPartEntity.ProgressListener listener;
    private long transferred;

    public CountingOutputStream(OutputStream paramOutputStream, CustomMultiPartEntity.ProgressListener paramProgressListener)
    {
      super();
      this.listener = paramProgressListener;
      this.transferred = 0L;
    }

    public void write(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
      throws IOException
    {
      this.out.write(paramArrayOfByte, paramInt1, paramInt2);
      this.transferred += paramInt2;
      this.listener.transferred(this.transferred);
    }

    public void write(int paramInt)
      throws IOException
    {
      this.out.write(paramInt);
      this.transferred += 1L;
      this.listener.transferred(this.transferred);
    }
  }

  public static abstract interface ProgressListener
  {
    public abstract void transferred(long paramLong);
  }
}

/* Location:           D:\hygieia\userclient\common\libs\easemobchat_2.1.8.jar
 * Qualified Name:     com.easemob.cloud.CustomMultiPartEntity
 * JD-Core Version:    0.6.1
 */